﻿@{
    ViewBag.Title = "Regist";
    Layout = "~/Views/Shared/_funcBase.cshtml";
    if (false)
    {
        <script src="~/LiberUI/Scripts/jquery-2.0.3.js"></script>
        <script src="~/LiberUI/Scripts/jquery.ba-resize.js"></script>
        <script src="~/LiberUI/Scripts/LiberUI.Base.js"></script>
        <script src="~/LiberUI/Scripts/LiberUI.Controllers.js"></script>
        <script src="~/LiberUI/Scripts/LiberUI.Action.js"></script>
        <script src="~/SiteUI/BaseScripts/site.js"></script>
    }
}
<style>
    #RegistForm{
        width:300px;
        height:400px;
        margin:auto;
        margin-top:200px;
    }
    #RegistForm>input{
        width:100%;
        margin-bottom:15px;
    }
    #RegistForm>label{
        font-size:1.2em;
        font-weight:bold;
    }
    #RegistForm>div{
        font-size:1.4em;
        width:100%;
        height:40px;
    }
</style>
<div id="RegistForm">
    <label for="txbAcnt">帐号</label>
    </br>
    <input id="txbAcnt" />
    </br>
    <label for="txbName">用户名</label>
    </br>
    <input id="txbName" />
    </br>
    <label for="pwdPass">登录密码</label>
    </br>
    <input id="pwdPass" type="password" />
    </br>
    <label for="pwdPassConfirm">确认密码</label>
    </br>
    <input id="pwdPassConfirm" type="password" />
    </br>
    </br>
    <div id="NewAccount">注册</div>
</div>
<script>
    function NewAccount() {
        if ($("#pwdPassConfirm").val() !== Env.Pass.val()) {
            alert("两次输入的密码不一致");
            return;
        }
        new AjaxHelper("get", "/Account/New", { acnt: Env.Acnt.val(),name:Env.Name.val(), pass: Env.Pass.val().MD5() }, onRegistOK);
    };

    function onRegistOK(rtn) {
        if (rtn.IsPositive) {
            alert("注册成功！Let's rock IT");
            window.location = "/Task/Index";
        }
        else {
            alert("注册失败，详细错误如下：" + rtn.Data);
        }
    };

    $(function () {
        Env.Acnt = $("#txbAcnt");
        Env.Pass = $("#pwdPass");
        Env.Name = $("#txbName");
        Env.btnNewAcnt = new Button($("#NewAccount")).on("click", NewAccount);
    })
</script>
